package com.xunfang.gateway;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.gateway.filter.factory.GatewayFilterFactory;
import org.springframework.cloud.gateway.filter.factory.PrefixPathGatewayFilterFactory;
import org.springframework.cloud.gateway.handler.predicate.AfterRoutePredicateFactory;

@EnableDiscoveryClient
@SpringBootApplication
public class GatewayApplication {

    //这个工程类就是对应  After 配置
    AfterRoutePredicateFactory afterRoutePredicateFactory;
    /**
     * 这个是断言配置
     *  - After=2023-04-06T10:15:38.866925800+08:00[Asia/Shanghai]
     * 这个断言器是怎么做的?
     *    有个拦截器  对应after 这个配置
     *        这个拦截器中写业务逻辑
     *
     *  流程:
     *     01 AfterRoutePredicateFactory 继承  AbstractRoutePredicateFactory
     *     02 重写
     *           public Predicate<ServerWebExchange> apply(Config config) {
     *                return  new GatewayPredicate() {
     * 			            @Override
                            public boolean test(ServerWebExchange serverWebExchange) {
                                写业务逻辑
                                和config中进行配置
                  				return 返回结果 ;
                           }
     *           }
     *
     *     03   AfterRoutePredicateFactory 这个类的名称必须是 XXXRoutePredicateFactory
     *          yaml配置必须是 AfterRoutePredicateFactory的名称 after
     *
     *
     *   和 上面的断言思路一样
     *   1、AbstractGatewayFilterFactory<PrefixPathGatewayFilterFactory.Config>
     *
     *   2、GatewayFilter apply(Config config) {
     * 		return new GatewayFilter() {
     *           filter(){
     *               写业务逻辑
     *           }
     * 		}
     *   3、在yaml 中配置
     *
     * @param args
     */
    PrefixPathGatewayFilterFactory GatewayFilterFactory;
//    StripPrefix
    public static void main(String[] args) {
        SpringApplication.run(GatewayApplication.class,args);
    }

}